import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Provider } from '@ant-design/react-native';
import * as Font from "expo-font";
import { Router, Route } from "./util/react-router";
import { Home } from "./pages/index/home";
import { Login } from "./pages/index/login";



export default function App() {
  const [userInfo, setUserInfo] = React.useState({ name: '', jobnum: '' });

  let [fontsLoaded] = useFonts({
    "antoutline": require('@ant-design/icons-react-native/fonts/antoutline.ttf')
  });

  if (!fontsLoaded) {
    return <View style={styles.container}><Text>加载中...</Text></View>;
  }

  return (
    <Router>
      <Provider>
        <Route exact path="/" component={Home}></Route>
        <Route path="/login" component={Login}></Route>
      </Provider>
    </Router>
  );
}

function useFonts(fontMap) {
  let [fontsLoaded, setFontsLoaded] = React.useState(false);
  (async () => {
    await Font.loadAsync(fontMap);
    setFontsLoaded(true);
  })();
  return [fontsLoaded];
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  }
});
